﻿using FilterIllegalCharacter.Core;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace FilterIllegalCharacter.UI
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {

            //base.OnStartup(e);
            //// 此处加载所有字典文件初始化过滤器
            //FilterHelper.Instance.InitDictionary(DictFileHelper.ReadAllDictFile());

            // 创建快捷方式
            if (e.Args.Contains("CreateShortcut"))
            {
                ShortcutHelper.CreateShortcut("敏感词过滤.lnk");
                this.Shutdown();
            }
            // 添加登录窗口逻辑，如果不需要登录逻辑直接使用上面注释的两行代码
            Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
            var login = new Login();
            login.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            if (login.ShowDialog() == true)
            {
                base.OnStartup(e);
                // 此处加载所有字典文件初始化过滤器
                FilterHelper.Instance.InitDictionary(DictFileHelper.ReadAllDictFile());
                Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
            }
            else
            {
                this.Shutdown();
            }
        }
    }
}
